package cn.lili.modules.mapper;

import cn.lili.modules.store.entity.vos.StoreVO;
import cn.lili.modules.urbansubstation.entity.dos.UrbanSubstation;
import cn.lili.modules.urbansubstation.entity.vos.UrbanSubstationVo;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UrbanSubstationMapper extends BaseMapper<UrbanSubstation> {

    @Select("select lus.*, lu.username, luw.balance from `lilishop_urban_substation`.li_urban_substation lus " +
            "LEFT join `lilishop_user`.li_user lu on  lus.user_id = lu.id " +
            "LEFT join `lilishop_payment`.li_user_wallet luw on lus.user_id = luw.user_id " +
            "${ew.customSqlSegment}")
    Page<UrbanSubstationVo> findByConditionPage(Page<UrbanSubstationVo> page, @Param(Constants.WRAPPER) Wrapper<StoreVO> queryWrapper);

    @Select("SELECT id,urban_name,area_id,area_name,province_id,province_name FROM li_urban_substation WHERE province_id = #{province} GROUP BY area_id;")
    List<UrbanSubstation> getOperationCenterUrbanSubstationList(String province);
}
